import {
  BaseEntity,
  Column,
  CreateDateColumn,
  DeleteDateColumn,
  Entity,
  ManyToOne,
  OneToMany,
  OneToOne,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from "typeorm";
import { Manager } from "./Manager";
import { Product } from "./Product";
import { Image } from "./Image";
import { User } from "./User";

@Entity()
export class Store extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: "varchar", length: 255 })
  name: string;

  @Column({ type: "varchar", length: 255 })
  image: string;

  @Column({ type: "varchar", length: 255 })
  phone: string;

  @Column({ type: "varchar", length: 255 })
  address: string;

  @CreateDateColumn()
  createTime: Date;

  @UpdateDateColumn()
  updateTime: Date;

  @DeleteDateColumn()
  deleteTime: Date;

  @OneToMany(() => User, (user) => user.store)
  users: User[];

  @OneToMany(() => Manager, (manager) => manager.store)
  managers: Manager[];

  @OneToMany(() => Product, (product) => product.store)
  products: Product[];

  @OneToMany(() => Image, (image) => image.store)
  images: Image[];
}
